<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>建立符号连接</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.stat.html">« stat</a></li>
      <li style="float: right;"><a href="function.tempnam.html">tempnam »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.filesystem.html">文件系统函数</a></li>
    <li>建立符号连接</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.symlink" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">symlink</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">symlink</span> &mdash; <span class="dc-title">建立符号连接</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.symlink-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>symlink</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$target</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$link</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>symlink()</strong></span> 对于已有的
   <code class="parameter">target</code> 建立一个名为
   <code class="parameter">link</code> 的符号连接。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.symlink-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">target</code></dt>

     <dd>

      <p class="para">
       连接的目标。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">link</code></dt>

     <dd>

      <p class="para">
       连接的名称。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.symlink-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.symlink-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果 <code class="parameter">link</code> 已存在，函数将失败，并发出
   <strong><code>E_WARNING</code></strong>。在 Windows 上，如果
   <code class="parameter">target</code> 不存在，函数也会失败，并发出
   <strong><code>E_WARNING</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.symlink-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2228">
    <p><strong>示例 #1 创建一个符号连接</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$target&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'uploads.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'uploads'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">symlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$target</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">readlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.symlink-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.link.html" class="function" rel="rdfs-seeAlso">link()</a> - 建立一个硬连接</span></li>
    <li class="member"><span class="function"><a href="function.readlink.html" class="function" rel="rdfs-seeAlso">readlink()</a> - 返回符号连接指向的目标</span></li>
    <li class="member"><span class="function"><a href="function.linkinfo.html" class="function" rel="rdfs-seeAlso">linkinfo()</a> - 获取一个连接的信息</span></li>
    <li class="member"><span class="function"><a href="function.unlink.html" class="function" rel="rdfs-seeAlso">unlink()</a> - 删除文件</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>